#ifndef QUERY_H
#define QUERY_H

#pragma once
#include <algorithm>
#include "ArchivoAuxiliar.h"
#include "ArchivoDocumentos.h"
#include "ParserUtils.h"
#include "mainwindow.h"

class Utils;

class Query: public ParserUtils {
private:
    Query();
    static Query* instance;

    ArchivoAuxiliar* i;
    vector<string> tokens;

    void process();
public:
    static Query* getInstance();
    void setTerminos(string term);
    void addToken(string token);
    static void destroyInstance();
    virtual ~Query();
};

class Utils {

public:

    static bool stringCompare (string a,string b) {
        return (a.compare(b)<0);
    }

    static int binarySearch (vector<string>::iterator first, vector<string>::iterator last, string val){

        vector<string>::iterator posIt=std::lower_bound(first,last,val,stringCompare);
        int pos=posIt -first;
        if(!(posIt!=last && !(val<*posIt)))
            pos=-1;
         return pos;
  }

};

#endif // QUERY_H
